package com.magnificent.atlantis.client.ui.creator;

import com.magnificent.atlantis.client.data.configuration.AbstractConfiguration;
import com.magnificent.atlantis.client.data.configuration.FileConfiguration;
import com.magnificent.atlantis.client.data.configuration.ServerConfiguration;
import com.magnificent.atlantis.client.data.task.creator.AbstractCreatorTask;

import java.util.List;

/**
 * User: Babanin
 * Date: 04.02.2009
 * Time: 17:18:05
 */
public class CreatorData {
    private String fileName;
    private FileConfiguration fileConfiguration;
    private AbstractConfiguration abstractConfiguration;

    public CreatorData() {
        fileConfiguration = new FileConfiguration();
    }

    public CreatorData(AbstractConfiguration configuration, List<AbstractCreatorTask> tasks) {
        abstractConfiguration = configuration;
        fileConfiguration = new FileConfiguration();

        fileConfiguration.setName(configuration.getName());
        fileConfiguration.setDescription(configuration.getDescription());

        if (abstractConfiguration.isServerConfiguration()) {
            ServerConfiguration serverConfiguration = (ServerConfiguration) abstractConfiguration;

            fileConfiguration.setServerConfiguration(true);
            fileConfiguration.setPort(serverConfiguration.getPort());
            fileConfiguration.setHost(serverConfiguration.getHost());
        }

        fileConfiguration.setFileTasks(tasks);
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public AbstractConfiguration getAbstractConfiguration() {
        return abstractConfiguration;
    }

    public void setAbstractConfiguration(AbstractConfiguration abstractConfiguration) {
        this.abstractConfiguration = abstractConfiguration;
    }

    public FileConfiguration getFileConfiguration() {
        return fileConfiguration;
    }

    public void setFileConfiguration(FileConfiguration fileConfiguration) {
        this.fileConfiguration = fileConfiguration;
    }
}
